package com.itheima;

import com.itheima.pojo.Goods;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringDataEsTemplate {

    @Autowired
    private ElasticsearchTemplate template;

    @Test
    public void deleteMapping(){
        boolean b = template.deleteIndex(Goods.class);
        System.out.println("删除索引库是否成功： " + b);
    }

    @Test
    public void createMapping(){
        boolean index = template.createIndex(Goods.class);
        System.out.println("创建索引库是否成功： " + index);
        boolean b = template.putMapping(Goods.class);
        System.out.println("创建类型是否成功： " + b);
    }

}
